package easychat;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.util.Scanner;

public class Sender {
    public static void main(String[] args) throws IOException {
        //发送端
        //1.创建socket对象
        Socket socket = new Socket("127.0.0.1",1002);
        //2.键盘录入信息
        Scanner sc = new Scanner(System.in);
        while(true){
            System.out.println("聊天框:");
            String str = sc.nextLine();
            if("88".equals(str)){
                break;
            }

            OutputStream os = socket.getOutputStream();
            os.write(str.getBytes());

        }

        //释放资源
        socket.close();
    }
}
